"""
pattern: 正则模式，一个正则字符串

"""
import re

# 包
# print(re)

# r = re.match(r'abc', 'abc456abc')
# print(r, type(r), r.group())

# r = re.fullmatch(r'a\w*c', 'abc456abc')
# print(r, type(r))


# 可以返回Match对象 最多只匹配一个  或者None
# r = re.search(r'abc', '123abc456abc')
# r = re.search(r'\w{3}', '123abc456')
# r = re.search(r'[a-z]+', '123abc456')

# print(r, type(r), dir(r))
# print(r.group(), r.span(), r.start(), r.end())

# 可以返回List  列表中存放字符串
# r = re.findall(r'abc', '123abc456abc')
# r = re.findall(r'[a-z]{3}', '123abc456abc')

# print(r, type(r))
# for e in r:
#     print(type(e), e)


# r = re.finditer(r'a\wc', '123abc456adc')
# # print(r, type(r))
# for e in r:
#     print(e, type(e), e.group())


# r = re.split(r'a\wc', '123abc456adc789')
# print(r, type(r))

# r = re.sub(r'a\wc', '醒醒啦', '123abc456adc789axc789', count=2)
# print(r, type(r))

# r = re.subn(r'a\wc', '醒醒啦', '123abc456adc789axc789', count=2)
# print(r, type(r))


# c = re.compile(r'a\wc')
# # print(c, type(c), dir(c))
# r = c.findall('abc123adc456aec789')
# print(r, type(c))


# r = re.findall(r'a.c', 'abc123adc456a\'c789a\nc555', re.S)
# print(r)

# r = re.findall(r'^a.c', 'abc123\nadc456', re.M)
# print(r)

# r = re.findall(r'^a.c\d\d\d$', 'abc123\nadc456', re.M)
# print(r)

# r = re.findall(r'^a.c\d', 'abc123\nadc456', re.M)
# print(r)


# r = re.findall(r'^a.c\d\w', 'abc12\nadc4l\nagc4_', re.M)
# print(r)


# r = re.findall(r'a.c\d\w\s', 'abc12\nadc4l\tagc4_ ')
# print(r)


# r = re.findall(r'\d\D\w\W\s\S', '2_a+ a')
# print(r)

# r = re.findall(r'a+?', 'aaaaa')
# print(r)

# r = re.findall(r'a*?', 'aaaaa')
# print(r)


# r = re.findall(r'a??', 'aaaaa')
# print(r)

# r = re.findall(r'\d.*?\d', 'abc123adc4565agc789')
# print(r)


# r = re.findall(r'a\w{1,3}c', 'abcaddcagggc')
# print(r)


# r = re.findall(r'a[1-9a-zA-Z=]c', 'abca1ca2ca3ca9ca=caycazcamc')
# print(r)


# r = re.search(r'(\d{3})(\w{3})', '123abc456def789')
# print(r, r.group(), r.group(1), r.group(2))


# r = re.findall(r'[\u4e00-\u9fa5]', '4556我ddd好像b睡一会儿')
# print(r)


# while True:
#     email = input("输入邮箱")
#     r = re.search(
#         r'[\w!#$%&\'*+/=?^_`{|}~-]+(?:\.[\w!#$%&\'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?',
#         email)
#     if r:
#         print(f"输入的是邮箱")
#         break
#     else:
#         pass

# while True:
#     tel = input("输入号码")
#     r = re.search(r'0?(13|14|15|18|17)[0-9]{9}', tel)
#     if r:
#         print(r.group())
#         breaks



